;
ff_vecs_t *find_vec(char *, char **);
void disp_vecs(void);
+void exit_vecs(void);
void disp_formats(int version);
void printposn(double c, int is_lat);
void
free_filter_vec( filter_vecs_t *fvec )
{
- if ( fvec->args && fvec->args->argval && *(fvec->args->argval) ) {
- xfree(*(fvec->args->argval));
+ arglist_t *ap;
+
+ if ( fvec->args ) {
+ for ( ap = fvec->args; ap->argstring; ap++) {
+ if (ap->argval && *ap->argval) xfree(*ap->argval);
+ }
}
}
for( Vertex = 0; Vertex < numberOfVerticies; Vertex++)
{
// read vertex position
- if( !readPositionRecord( pFile, &lat2, &lng2, pts2) )
+ if( !readPositionRecord( pFile, &lat2, &lng2, pts2) ) {
+ xfree(wpt_tmp);
return;
+ }
wpt_tmp->longitude = lng2;
wpt_tmp->latitude = lat2;
// read the class name
- if( !readRecord( pFile, EF_CLNM_REC, className) )
+ if( !readRecord( pFile, EF_CLNM_REC, className) ) {
+ xfree( wpt_tmp );
return;
+ }
// read the attributes name
- if( !readRecord( pFile, EF_ATTR_REC, attr) )
+ if( !readRecord( pFile, EF_ATTR_REC, attr) ) {
+ xfree( wpt_tmp );
return;
+ }
getAttr(attr, ATTR_OBJECTNAME, &wpt_tmp->shortname, '\x1f');
getAttr(attr, ATTR_USRMRK, &wpt_tmp->description, '\x1f');
static void mag_readmsg(void);
static void mag_handon(void);
static void mag_handoff(void);
-static void *mkshort_handle;
-static char *deficon;
-static char *bs;
-static char *noack;
-static char *nukewpt;
+static void *mkshort_handle = NULL;
+static char *deficon = NULL;
+static char *bs = NULL;
+static char *noack = NULL;
+static char *nukewpt = NULL;
static int route_out_count;
static int waypoint_read_count;
waypt_flush_all();
route_flush_all();
+ exit_vecs();
exit_filter_vecs();
#ifdef DEBUG_MEM
int lon;
int icon;
- waypoint *thisWaypoint;
+ waypoint *thisWaypoint = NULL;
double mps_altitude = unknown_alt;
double mps_proximity = unknown_alt;
double mps_depth = unknown_alt;
/* The following Now done elsewhere since it can be useful to read in and
perhaps not add to the list */
/* waypt_add(thisWaypoint); */
-
+
return;
}
fprintf(stderr,"Lost sync with the file reading waypoint - %s\n", wpt->shortname);
#endif
fseek (mps_file_in, mpsFileInPos + reclen, SEEK_SET);
+ waypt_free( wpt );
}
else {
/* only add to the "real" list if a "user" waypoint otherwise add to the private list */
if (mpsWptClass == MPSDEFAULTWPTCLASS) waypt_add(wpt);
- else mps_wpt_q_add(&read_route_wpt_head, wpt);
+ else {
+ mps_wpt_q_add(&read_route_wpt_head, wpt);
+ waypt_free( wpt );
+ }
#ifdef DUMP_ICON_TABLE
printf("\t{ %4u, \"%s\" },\n", icon, wpt->shortname);
#endif
since we're here because the user didn't request waypoints, this should be acceptable */
mps_waypoint_r(mps_file_temp, mps_ver_temp, &wpt, &mpsWptClass);
mps_wpt_q_add(&written_wpt_head, wpt);
+ waypt_free( wpt );
/* now return to the start of the waypoint data to do a "clean" copy */
fseek(mps_file_temp, tempFilePos, SEEK_SET);
if (recType == 'W') {
/* need to be careful that we aren't duplicating a wpt defined from elsewhere */
mps_waypoint_r(mps_file_temp, mps_ver_temp, &wpt, &mpsWptClass);
- if (mpsWptClass == MPSDEFAULTWPTCLASS) waypt_add(wpt);
+ if (mpsWptClass == MPSDEFAULTWPTCLASS) waypt_add(wpt);else waypt_free(wpt);
}
else break;
}
static char *seicon = "Red Diamond";
static char *sneicon = "Green Diamond";
static char *snmac = NULL;
+static char *optnseicon = NULL;
+static char *optnsneicon = NULL;
+static char *optseicon = NULL;
+static char *optsneicon = NULL;
static void fix_netstumbler_dupes(void);
static
arglist_t netstumbler_args[] = {
- {"nseicon", &nseicon, "Non-stealth encrypted icon name", ARGTYPE_STRING },
- {"nsneicon", &nsneicon, "Non-stealth non-encrypted icon name", ARGTYPE_STRING },
- {"seicon", &seicon, "Stealth encrypted icon name", ARGTYPE_STRING },
- {"sneicon", &sneicon, "Stealth non-encrypted icon name", ARGTYPE_STRING },
+ {"nseicon", &optnseicon, "Non-stealth encrypted icon name", ARGTYPE_STRING },
+ {"nsneicon", &optnsneicon, "Non-stealth non-encrypted icon name", ARGTYPE_STRING },
+ {"seicon", &optseicon, "Stealth encrypted icon name", ARGTYPE_STRING },
+ {"sneicon", &optsneicon, "Stealth non-encrypted icon name", ARGTYPE_STRING },
{"snmac", &snmac, "Shortname is MAC address", ARGTYPE_BOOL },
{0, 0, 0, 0}
};
static void
rd_init(const char *fname)
{
+ nseicon = optnseicon?optnseicon:"Red Square";
+ nsneicon = optnsneicon?optnsneicon:"Green Square";
+ seicon = optseicon?optseicon:"Red Diamond";
+ sneicon = optsneicon?optsneicon:"Green Diamond";
file_in = xfopen(fname, "r", MYNAME);
}
static FILE *file_in;
static FILE *file_out;
static void *mkshort_handle;
+static char *optdeficon = NULL;
static char *deficon = "Waypoint";
#define MYNAME "PCX"
static
arglist_t pcx_args[] = {
- {"deficon", &deficon, "Default icon name", ARGTYPE_STRING },
+ {"deficon", &optdeficon, "Default icon name", ARGTYPE_STRING },
{0, 0, 0, 0}
};
static void
rd_init(const char *fname)
{
+ if ( optdeficon ) {
+ deficon = optdeficon;
+ }
+ else {
+ deficon = "Waypoint";
+ }
file_in = xfopen(fname, "r", MYNAME);
}
static void
wr_init(const char *fname)
{
+ if ( optdeficon ) {
+ deficon = optdeficon;
+ }
+ else {
+ deficon = "Waypoint";
+ }
file_out = xfopen(fname, "w", MYNAME);
mkshort_handle = mkshort_new_handle();
}
int rec_cnt;
static char *nolabels = NULL;
static char *genurl = NULL;
+static char *suppresswhite = NULL;
+static char *iconismarker = NULL;
+static char *snlen = NULL;
+
static char *margin = "15%";
static char *xpixels = "768";
static char *ypixels = "768";
-static char *snlen = NULL;
static char *oldthresh = "14";
static char *oldmarker = "redpin";
static char *newmarker = "greenpin";
static char *unfoundmarker = "bluepin";
-static char *suppresswhite = NULL;
-static char *iconismarker = NULL;
+
+static char *optmargin = NULL;
+static char *optxpixels = NULL;
+static char *optypixels = NULL;
+static char *optoldthresh = NULL;
+static char *optoldmarker = NULL;
+static char *optnewmarker = NULL;
+static char *optunfoundmarker = NULL;
int scalev;
int short_length;
ARGTYPE_BOOL },
{"genurl", &genurl, "Generate file with lat/lon for centering map.",
ARGTYPE_OUTFILE },
- {"margin", &margin, "Margin for map. Degrees or percentage.",
+ {"margin", &optmargin, "Margin for map. Degrees or percentage.",
ARGTYPE_FLOAT},
{"snlen", &snlen, "Max shortname length when used with -s.",
ARGTYPE_INT},
- {"oldthresh", &oldthresh, "Days after which points are considered old.",
+ {"oldthresh", &optoldthresh, "Days after which points are considered old.",
ARGTYPE_INT},
- {"oldmarker", &oldmarker, "Marker type for old points.",
+ {"oldmarker", &optoldmarker, "Marker type for old points.",
ARGTYPE_STRING},
- {"newmarker", &newmarker, "Marker type for new points.",
+ {"newmarker", &optnewmarker, "Marker type for new points.",
ARGTYPE_STRING},
{"suppresswhite", &suppresswhite,
"Suppress whitespace in generated shortnames", ARGTYPE_BOOL },
- {"unfoundmarker", &unfoundmarker, "Marker type for unfound points.",
+ {"unfoundmarker", &optunfoundmarker, "Marker type for unfound points.",
ARGTYPE_STRING},
- {"xpixels", &xpixels, "Width in pixels of map.",
+ {"xpixels", &optxpixels, "Width in pixels of map.",
ARGTYPE_INT},
- {"ypixels", &ypixels, "Height in pixels of map.",
+ {"ypixels", &optypixels, "Height in pixels of map.",
ARGTYPE_INT},
{"iconismarker", &iconismarker,
"The icon description is already the marker", ARGTYPE_BOOL },
static void
rd_init(const char *fname)
{
+ margin = optmargin?optmargin:"15%";
+ xpixels = optxpixels?optxpixels:"768";
+ ypixels = optypixels?optypixels:"768";
+ oldthresh = optoldthresh?optoldthresh:"14";
+ oldmarker = optoldmarker?optoldmarker:"redpin";
+ newmarker = optnewmarker?optnewmarker:"greenpin";
+ unfoundmarker = optunfoundmarker?optunfoundmarker:"bluepin";
file_in = xfopen(fname, "r", MYNAME);
mkshort_handle = mkshort_new_handle();
}
static void
wr_init(const char *fname)
{
+ margin = optmargin?optmargin:"15%";
+ xpixels = optxpixels?optxpixels:"768";
+ ypixels = optypixels?optypixels:"768";
+ oldthresh = optoldthresh?optoldthresh:"14";
+ oldmarker = optoldmarker?optoldmarker:"redpin";
+ newmarker = optnewmarker?optnewmarker:"greenpin";
+ unfoundmarker = optunfoundmarker?optunfoundmarker:"bluepin";
file_out = xfopen(fname, "w", MYNAME);
thresh_days = strtod(oldthresh, NULL);
}
}
};
+void
+exit_vecs( void )
+{
+ vecs_t *vec = vec_list;
+ while ( vec->vec ) {
+ arglist_t *ap;
+ if ( vec->vec->args ) {
+ for ( ap = vec->vec->args; ap->argstring; ap++ ) {
+ if ( ap->argval && *ap->argval ) {
+ xfree(*ap->argval);
+ *ap->argval = NULL;
+ }
+ }
+ }
+ vec++;
+ }
+}
+
ff_vecs_t *
find_vec(char *const vecname, char **opts)
{
if (vec->vec->args) {
for (ap = vec->vec->args; ap->argstring; ap++){
- void *av;
- av = get_option(*opts, ap->argstring);
- if (av) {
- *ap->argval = av;
- }
+ if ( *ap->argval ) xfree(*ap->argval);
+ *ap->argval = get_option(*opts, ap->argstring);
}
}
} else {